package com.eleadmin.ocean.controller;

import com.eleadmin.damon.utils.results.PageResult2;
import com.eleadmin.common.core.web.*;
import com.eleadmin.common.core.annotation.OperationLog;
import com.eleadmin.ocean.entity.OceanBulkCargoFeeAttach;
import com.eleadmin.ocean.service.OceanBulkCargoFeeAttachService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;


/**
 *
 * 海运散货附加费维护
 * @author : Doman
 * @date : 2024-08-05 17:33:17
 * @version ：1.0
 */

@Api(tags = "海运散货附加费维护")
@RestController
@RequestMapping("/api/ocean/oceanBulkCargoFeeAttach")
public class OceanBulkCargoFeeAttachController extends BaseController {

    @Autowired
    private OceanBulkCargoFeeAttachService oceanBulkCargoFeeAttachService;

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:list')")
    //@ApiOperation("分页查询海运散货附加费维护")
    @GetMapping("/page")
    public JsonResult page(PageResult2<T> page, OceanBulkCargoFeeAttach oceanBulkCargoFeeAttach) throws Exception{
        return oceanBulkCargoFeeAttachService.list(page, oceanBulkCargoFeeAttach, getLoginUser());
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:list')")
    //@ApiOperation("查询全部海运散货附加费维护")
    @GetMapping()
    public JsonResult list(OceanBulkCargoFeeAttach oceanBulkCargoFeeAttach){
        return oceanBulkCargoFeeAttachService.list(oceanBulkCargoFeeAttach, getLoginUser());
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:list')")
    @ApiOperation("返回海运散货附加费维护select列表")
    @GetMapping("listSel")
    public JsonResult listSel(OceanBulkCargoFeeAttach oceanBulkCargoFeeAttach){
        return oceanBulkCargoFeeAttachService.listSel(oceanBulkCargoFeeAttach, getLoginUser());
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:list')")
    //@ApiOperation("根据id查询海运散货附加费维护")
    @GetMapping("/{id}")
    public JsonResult get(@PathVariable("id") String id) {
        return oceanBulkCargoFeeAttachService.getById(id);
    }


    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:save')")
    @OperationLog
    @ApiOperation(value ="添加海运散货附加费维护")
    @PostMapping()
    public JsonResult save(@RequestBody OceanBulkCargoFeeAttach oceanBulkCargoFeeAttach) {
        try {
            return oceanBulkCargoFeeAttachService.save(oceanBulkCargoFeeAttach, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }

    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:update')")
    @OperationLog
    @ApiOperation(value ="修改海运散货附加费维护")
    @PutMapping()
    public JsonResult update(@RequestBody OceanBulkCargoFeeAttach oceanBulkCargoFeeAttach) {
        try {
            return oceanBulkCargoFeeAttachService.update(oceanBulkCargoFeeAttach, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoFeeAttach:remove')")
    @OperationLog
    @ApiOperation(value ="删除海运散货附加费维护")
    @DeleteMapping("/{id}")
    public JsonResult remove(@PathVariable("id") String id) {
        try {
            return oceanBulkCargoFeeAttachService.remove(id, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }
    }

}
